import request from './index'
import { INF_NewParams } from '@/receivePages/pre/initState'

// 入住列表
export const VIRTUAL = 'VIRTUAL'
export const DU = 'DU'
export const HU = 'HU'
export const ALL = 'ALL'

export type TYPE_ReceiveClass =
  | typeof VIRTUAL
  | typeof DU
  | typeof HU
  | typeof ALL
  | ''
export interface INF_ReceiveListV1_params {
  page: number
  limit: number
  ReceiveInClass: TYPE_ReceiveClass
}
export interface INF_ReceiveListV1_res {
  Items: Array<INF_ReceiveListV1_info>
  Count: number // 总数
  Page: number
}
export function ReceiveListV1(data: INF_ReceiveListV1_params) {
  return request({
    url: '/Receive/ReceiveListV1',
    method: 'post',
    data
  })
}

// 根据房态图选择的房型id，和酒店X-Tenant 判断当前房型下是否有可以办理入住的房间列表
export interface INF_IfCanCheckIn_params {
  id: number
}
export function IfCanCheckIn(data: INF_IfCanCheckIn_params) {
  return request({
    url: '/Receive/IfCanCheckIn',
    data
  })
}

// 如果新办理入住，没有房型id，则根据当前时间后12个小时，查询该时间段闲置的所有房型供以选择
export interface INF_GetFreeRoomForCheckInV1_params {
  WillLeave: string
  Hid: number
}

export interface INF_GetFreeRoomForCheckInV1_res {
  HomeClassId: any // 房型id
  HomeName: string // 房型名称
  RoomNos: string[]
  Price: number
  Rackrate?: number
}
export function GetFreeRoomForCheckInV1(
  data: INF_GetFreeRoomForCheckInV1_params
) {
  return request({
    url: '/SelfCheckin/GetFreeRoomForCheckInV1',
    data
  })
}

export type TYPE_BookType = 'Ordinary' | 'Team' | 'Link'

export interface INF_ReceiveListV1_info {
  Id: string
  Room: string
  TheClass: string // 散客
  CheckIn: string | null
  CheckOut: string | null
  WillLeave: string | null
  Price: number
  Days: number
  AllXf: number
  AllYj: number
  AllYsq: number
  State: string
  ServiceMan: string
  Cashier: null | any
  ManNum: number
  DR: number
  NormalPrice: number
  DateMan: string
  DateManDate: string
  CheckOutDateMan: null | string
  CheckOutDateManDate: null | string
  Note: string
  TheCompany: string
  ReceiveInClass: string
  RoomClass: string
  RoomClassId: number
  Floor: number
  XsName: string
  VipNo: string
  VipId: number
  VipLev: string
  LinkId: null | string
  BillId: string
  GuestName: string
  Tel: string
  Secret: boolean
  TheCompanyId: number
  BreakFastNum: number
  BookId: null | string
  BookServiceMan: null | string
  BookMan: null | string
  Notice: string
  MoveToId: null | string
  ReceiveMan: Array<any>
  ReceivePortions: null | string
  SexList: string
  Zk: number
  HasPricePlan: boolean
  TimeoutPrice: null | string
  InvoiceTotal: number
  Lunch: number
  Dinner: number
  xmin: number
  BookType: TYPE_BookType
  rentalItems: null | Array<any>
}

// 入住单详情
export interface INF_ReceiveInfoV1_res {
  State: string
  CheckInDate: string
  ReceiveId: string
  XiaoFei: number
  FuKuan: number
  Ysq: number
  Service: string
  Rackrate: number
  LinkId: string
  Links: Link[]
  IsLinks: boolean
  NormalPrice: number
  BillId: string
  BookServiceMan: string
  MoveToId: null | string
  CheckOut: null | string
  BookMan: string
  PortionIds: string[]
  NoticeEx: null
  HasPricePlan: boolean
  InvoiceTotal: number
  Amountto: number
  BookType: TYPE_BookType
  ZKName: string
  rentalItems: null
  CheckOutDateMan: null
  CheckOutDateManDate: null
  Room: string
  RoomClass: string
  TheClass: string
  WillLeave: string
  Price: number
  Days: number
  Note: string
  Notice: null
  TheCompany: string
  TheCompanyId: number
  Secret: boolean
  BreakFastNum: number
  Lunch: number
  Dinner: number
  ReceiveClass: number
  XsName: string
  VipNo: string
  VipId: null
  VipLev: string
  GuestName: string
  Tel: string
  BookId: string
  ReceiveMan: ReceiveMan[]
  Pay: null
  Zk: number
  TimeoutPrice: null
  HeadImg: null
}

interface Link {
  ReceiveId: string
  State: string
  RoomNo: string
  RoomClass: string
  GuestName: string
  XiaoFei: number
  FuKuan: number
  Ysq: number
  Master: boolean
  Days: number
  CheckIn: string
  Notice: null
  Price: number
  MasterType: number
}

interface ReceiveMan {
  id: number
  idType: number
  Key: number
  Code: string
  Name: string
  Tel: string
  Sex: string
  VipNo: string
  VipLev: string
  VipId: null
  MainFlag: boolean
  Addr: string
  Note: string
  Birt: null
  Price: number
  RoomClass: null
  CheckIn: string
  CheckOut: null
  RoomNo: null
  Nation: string
  headPhoto: null
  CertificatePhoto: null
  ForeignGuests: boolean
  NationRegion: null
  Reasons: null
}
export interface INF_ReceiveInfoV1_params {
  id: string // 房号id
}
export function ReceiveInfoV1(data: INF_ReceiveInfoV1_params) {
  return request({
    url: '/SelfCheckin/ReceiveInfoV1',
    data
  })
}

// 获取日志详情
export interface INF_OpLogs_params {
  Page: number
  Limit: number
  Room: string
  ReceiveId: string
}

export function getOpLogs(data: INF_OpLogs_params) {
  return request({
    url: '/System/OpLogs',
    data
  })
}

// 新入住
export interface INF_NewCheckIn_res {
  Id: string // 入住详情id
}
export function NewCheckIn(data: INF_NewParams) {
  return request({
    url: '/SelfCheckin/NewCheckIn',
    method: 'post',
    data
  })
}
